import { Component } from '@angular/core';
import { NavController, NavParams, Platform } from 'ionic-angular';
import { UrlService } from '../../providers/url-service';

/**
 * 
 *消息
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */
@Component({
  selector: 'page-message',
  templateUrl: 'message.html',
})
export class MessagePage {
  /**
   * 默认选中消息
   */
  pet: string = "message";
  /**
   * 消息列表
   */
  messageList = [];
  /**
   * 通知列表
   */
  noticeList = [];
  constructor(
    public platform: Platform,
    public urlService: UrlService,
    public navCtrl: NavController,
    public navPar: NavParams
  ) {
  }


  /**
   * 页面初始化加载
   */
  ionViewDidLoad() {
    this.getMessageList();
  }

  /**
   * 删除消息
   * 
   */
  removeItem(item) {
    //console.log("删除");
    //console.log(item);
    this.noticeList.splice(item, 1);
  }
  doRefresh(event) {
    //console.log(event);
    setTimeout(() => {
      this.getMessageList();
      event.complete();
    }, 2000);
  }
  /**
   * 获取消息列表
   */
  getMessageList() {

    let id = this.urlService.getUserinfo("UserID");
    let PhoneNumber = this.urlService.getUserinfo("PhoneNumber");
    this.urlService.getMessageList(id, PhoneNumber)
      .then(data => {
        //console.log("获取消息列表");
        //console.log(data);
        this.messageList = data.Data;

      })
  }

}
